package cm.util.action.info;

import cm.util.action.util.ActionUtil;
import cm.util.exception.MessageException;

import com.opensymphony.xwork2.ActionSupport;

/**
 * 
 * @author 苏玮
 * 2010-11-29
 */
public abstract class InfoActionSupport extends ActionSupport implements InfoAction {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2268682441049248139L;

	
	
	/**
	 * 操作的类型
	 */
	String type;
	
	/**
	 * 跳转控制参数
	 */
	private String forward;
	
	public InfoActionSupport(){
		super();
	}

	@Override
	public String execute()
			throws Exception {
		// TODO Auto-generated method stub
		/**
		 *强制转换，以获得操作的类型
		 */
		type = getType();
		System.out.println("started!");
		if (type == null) {
			throw new MessageException("对不起，操作类型不能为空！");
		} else if (ADD.equals(type)) {
			forward = add();
		} else if (DETAIL.equals(type)) {
			forward = detail();
		} else if (DELETE.equals(type)) {
			forward = delete();
		} else if (UPDATE.equals(type)) {
			forward = update();
		} else if(TO_UPDATE.equals(type)){
			forward =to_update();
		}else {
			throw new MessageException("对不起，不存在该操作类型！ type=" + type);
		}

		return forward;
	}



	public String add() throws MessageException {
		// TODO Auto-generated method stub
		return null;
	}

	public String delete() throws MessageException {
		// TODO Auto-generated method stub
		return null;
	}

	public String detail() throws MessageException {
		// TODO Auto-generated method stub
		return null;
	}

	public String to_update() throws MessageException {
		// TODO Auto-generated method stub
		return null;
	}

	public String update() throws MessageException {
		// TODO Auto-generated method stub
		return null;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	protected boolean isNull(Object property){
		return ActionUtil.isNull(property);
	}
}
